standardized-audio-context
A patched AudioContext which imitates the current API in current browsers.

This is a hopelessly naive attempt to patch the current implementation of the Web Audio API's
AudioContext
in current browsers. The
goal is to make them all behave as promised by the
Specification.
There are of course some things which cannot be faked in a reasonable way. The most obvious amongst
those is the AudioWorkerNode
which is currently not implemented by any browser. Therefore the corresponding
createAudioWorker()
method is missing here, too. All implemented methods are covered by unit
tests.
That said, there are a lot of other functions which are currently not implemented for no specific
reason besides a lack of time: createAudioWorker()
, createConvolver()
,
createDelay()
, createDynamicsCompressor()
, createMediaElementSource()
,
createMediaStreamDestination()
, createMediaStreamSource()
, createPanner()
,
createPeriodicWave()
, createScriptProcessor()
, createStereoPanner()
, createWaveShaper()
,
resume()
and suspend()
. The listener
property is also missing for now.
This module also provides an
OfflineAudioContext
which does
only expose the destination
, length
and sampleRate
attributes as well as the createGain()
and decodeAudioData()
methods up to now.
Usage
The standardized-audio-context
is available on
npm and can be installed as usual.
npm install standardized-audio-context
You can then import the AudioContext
and OfflineAudioContext
into your module like this:
import { AudioContext, OfflineAudioContext } from 'standardized-audio-context';
In addition to that the standardized-audio-context
also exports a promise named isSupported
which resolves to a boolean which indicates support within the currently used browser.
import { isSupported } from 'standardized-audio-context';
isSupported
.then((isSupported) => {
if (isSupported) {
} else {
}
});
Tests
Many thanks to BrowserStack and Sauce Labs for allowing this module to be tested with their services.